<?php
session_start();
require("../database.php");
include("header.php");

?>
<link href="../quiz.css" rel="stylesheet" type="text/css">

<SCRIPT LANGUAGE="JavaScript">
function check() {

alert("Do you want to delete");

return true;
}
</script>

<?php
extract($_POST);

echo "<BR>";
if (!isset($_SESSION[alogin]))
{
	echo "<br><h2><div  class=head1>You are not Logged On Please Login to Access this Page</div></h2>";
	echo "<a href=index.php><h3 align=center>Click Here for Login</h3></a>";
	exit();
}
if($_REQUEST[del_id])
{
$que_del_id=$_REQUEST[del_id];
$del_que=mysql_query("delete from mst_subject where sub_id=$_REQUEST[del_id]");
$del_test_id=mysql_query("select test_id from mst_test where sub_id=$_REQUEST[del_id]");
$del_test_result=mysql_fetch_array($del_test_id);

$del_sub_query=mysql_query("delete from mst_test where sub_id=$_REQUEST[del_id]");
for($i=0;$i<mysql_num_rows($del_test_id);$i++)
{
echo $del_test_result[$i];
echo "</br>";
mysql_query("delete from mst_question where test_id=$del_test_result[$i]");
}
//echo "sub has been deleted Succesfully</br>";

}

$sub_query = mysql_query("select * from mst_subject",$cn) or die(mysql_error());

echo $sub_result[0];
echo "</br>";
echo "<table border=1 align=center><tr class=style2> <td>S.No</td><td>sub</td> <td>Delete</td>";
for($i=0;$i<mysql_num_rows($sub_query);$i++)
{
$j=$i+1;
$sub_result = mysql_fetch_array($sub_query);
echo "<tr class=style8><td>$j</td><td> $sub_result[1] </td><td align=center><a href='view_all_subject.php?del_id=$sub_result[0]' onclick='return check();'><img src='images/b_deltbl.png' alt='Delete' title='Delete'></img></a></td>";
}
unset($_POST);

?>
